# -*- coding:utf-8 -*-
# author： jf


import requests
import re


def getphoto(url):

        headers = {
                    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) '
                    'AppleWebKit/537.36 (KHTML, like Gecko) '
                    'Chrome/63.0.3239.132 Safari/537.36'
              }

        """
        url = 'https://car.autohome.com.cn/pic/series/901-1-p3.html'
        response = requests.get(url, headers=headers)
        html = response.text
        print(response.status_code)
        reg = re.compile('<li><a href="(.*?)" title="(.*?)" target="_blank">')
        info = re.findall(reg, html)
        print(info)

        """

        response1 = requests.get(url, headers=headers)
        html1 = response1.text
        reg = re.compile('<img id="img" src="(.*?)" onside="-1" />')
        image = re.findall(reg, html1)

        url2 = 'https:' + image[0]
        print(url2)
        ptoto1 = image[0].split('/')[-1]
        response2 = requests.get(url2, headers=headers)
        photo = response2.content
        m = 1
        with open(r'F:\python1\file\图片\汽车之家\%s' % ptoto1, 'wb') as f:
            f.write(photo)
            m +=1
        reg1 = re.findall(r" var nexturl = '(.*?)'", html1)
        print('https://car.autohome.com.cn' + reg1[0])
        url = 'https://car.autohome.com.cn' + reg1[0]
        getphoto(url)


getphoto('https://car.autohome.com.cn/photo/series/18776/1/2424926.html')